Skip to content

[JExtract] Generate JNI code for memory management with SwiftKitCore #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 11, 2025

Conversation

madsodgaard
Copy link
Contributor

@madsodgaard madsodgaard commented Jul 10, 2025

Adds SwiftKitCore support for the generated code for classes. This means that we will actually destroy the instances once the arena decides to so.

@madsodgaard madsodgaard changed the title [WIP] [JExtract] Generate code for memory management with SwiftKitCore [WIP] [JExtract] Generate JNI code for memory management with SwiftKitCore Jul 10, 2025
@@ -40,8 +41,10 @@ static void examples() {

MySwiftClass.method();

MySwiftClass myClass = MySwiftClass.init(10, 5);
MySwiftClass myClass2 = MySwiftClass.init();
try (var arena = new ConfinedSwiftMemorySession(Thread.currentThread())) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick that this may want to be SwiftArena.ofConfined()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, but the problem is that Java 7 does not support static methods on interfaces.

Copy link
Collaborator

@ktoso ktoso Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh... heh I wonder if we need to really support so long back, we'll see as we chat with android workgroup.

Otherwise the Java pattern is to do a type like SwiftArenas that's a class and put the static methods on that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least we can make a () constructor that gets the current thread as well then, we can do this in a follow up

@madsodgaard madsodgaard marked this pull request as ready for review July 11, 2025 16:22
@madsodgaard madsodgaard changed the title [WIP] [JExtract] Generate JNI code for memory management with SwiftKitCore [JExtract] Generate JNI code for memory management with SwiftKitCore Jul 11, 2025
@madsodgaard madsodgaard requested a review from ktoso July 11, 2025 16:22
@ktoso ktoso merged commit ac80400 into swiftlang:main Jul 11, 2025
82 of 84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants